/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2023. All rights reserved.
 */

package toolcbc

import (
	"net/http"

	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/def"
)

const (
	//查询客户信用额度URL
	queryCreditCouponsURL = "/v2/partners/sub-customers/credit-coupons/query"
	//调整客户信用额度URL
	adjustCloudCreditCouponURL = "/v2/partners/sub-customers/credit-coupons"
	//查询调整客户信用额度URL
	queryCloudCreditRecordURL = "/v2/partners/sub-customers/credit/records"
)

// 生成查询客户信用额度响应
func GenReqDefForQueryCreditCoupons() *def.HttpRequestDef {
	reqDefBuilder := def.NewHttpRequestDefBuilder().
		WithMethod(http.MethodPost).
		WithPath(queryCreditCouponsURL).
		WithResponse(new(QueryCloudCreditCouponsResponse)).
		WithContentType("application/json")

	reqDefBuilder.WithRequestField(def.NewFieldDef().WithName("Body").WithLocationType(def.Body))

	request := reqDefBuilder.Build()
	return request
}

// 生成调整客户信用额度响应
func GenReqDefForAdjustCloudCreditCoupon() *def.HttpRequestDef {
	reqDefBuilder := def.NewHttpRequestDefBuilder().
		WithMethod(http.MethodPut).
		WithPath(adjustCloudCreditCouponURL).
		WithResponse(new(AdjustCloudCreditCouponReponse)).
		WithContentType("application/json")

	reqDefBuilder.WithRequestField(def.NewFieldDef().WithName("Body").WithLocationType(def.Body))

	request := reqDefBuilder.Build()
	return request
}

// 生成查询调整客户信用额度记录响应
func GenReqDefForQueryCloudCreditRecord() *def.HttpRequestDef {
	reqDefBuilder := def.NewHttpRequestDefBuilder().
		WithMethod(http.MethodGet).
		WithPath(queryCloudCreditRecordURL).
		WithResponse(new(QueryCloudCreditRecordResponse)).
		WithContentType("application/json")

	reqDefBuilder.WithRequestField(def.NewFieldDef().WithName("CustomerId").WithJsonTag("customer_id").WithLocationType(def.Query))
	reqDefBuilder.WithRequestField(def.NewFieldDef().WithName("Offset").WithJsonTag("offset").WithLocationType(def.Query))
	reqDefBuilder.WithRequestField(def.NewFieldDef().WithName("Limit").WithJsonTag("limit").WithLocationType(def.Query))
	request := reqDefBuilder.Build()
	return request
}
